package com.jt.demo7;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

@Component
//当spring容器启动时，加载指定的配置文件，将数据保存到容器中
@PropertySource(value="classpath:/dept.properties",encoding = "utf-8")
public class Dept {
    //取值方式：从spring中获取数据￥{Pro中的key}
    @Value("${dept.id}")
    private Integer id;
    @Value("${dept.name}")
    private  String name;

    public void helllo(){
        System.out.println("获取数据;"+id+":"+name);
    }
}
